package com.yjhb.android.sbz.v2.dialog

import android.app.Activity
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.yjhb.android.sbz.R
import com.jojo.android.zxlib.base.BaseDialog
import com.jojo.android.zxlib.tool.ZxToast
import kotlinx.android.synthetic.main.dialog_customer.*
import kotlinx.android.synthetic.main.dialog_leader.close_iv


/**
 *  创建者 zx
 *  创建时间 2021/5/24 16:35
 */
class ContactCustomerDialog(activity: Activity) : BaseDialog(activity) {

    override fun init() {
        close_iv?.setOnClickListener { dismiss() }
        loading_view?.setColor(Color.BLACK)
        image_iv?.let {
            Glide.with(context)
                    .load("https://shangbangzhuan.oss-cn-beijing.aliyuncs.com/commonImages/business_icon.jpg")
                    .addListener(object : RequestListener<Drawable?> {
                        override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable?>?, isFirstResource: Boolean): Boolean {
                            ZxToast.showBottomToastLight("二维码加载失败！请退出后重试！")
                            return false
                        }

                        override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable?>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
                            loading_view?.visibility = View.GONE
                            return false
                        }
                    })
                    .into(it)
        }
    }

    override fun getLayoutId() = R.layout.dialog_customer
}